<template>
  <div class="page">
    <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
          <div class="layui-card">

            <div class="layui-card-body cardbody">
              <div class="layui-form" lay-filter="">

                <div class="layui-form-item">
                  <label class="layui-form-label">门店名称:</label>
                  <div class="layui-input-block">
                    <input type="text" name="title" autocomplete="off" placeholder="请输入您的门店名称" class="layui-input"
                      style="width: 180px;">
                  </div>
                </div>

                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">logo:</label>
                    <div class="layui-input-inline" style="width: 180px;">
                      <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test1">
                          logo
                        </button>
                        <img class="layui-upload-img" id="demo1"
                          :src="itemData.logo?itemData.logo:'http://kedoujfpc.tongdui365.com/static/common/image/zwyl.jpg'"
                          width="100" height="100" style="border:1px solid #eee;">
                        <p id="demoText"></p>
                      </div>
                    </div>
                  </div>
                </div>

                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">欢迎界面:</label>
                    <div class="layui-input-inline" style="width: 180px;">
                      <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test2">
                          界面图片
                        </button>
                        <img class="layui-upload-img" id="demo2"
                          :src="itemData.logo?itemData.logo:'http://kedoujfpc.tongdui365.com/static/common/image/zwyl.jpg'"
                          width="100" height="100" style="border:1px solid #eee;">
                        <p id="demoText"></p>
                      </div>
                    </div>
                  </div>
                </div>

                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <button class="layui-btn  layui-btn-normal">保存</button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>

export default {
  name: 'usersetadd',
  data () {
    return {
      id: "",
      itemData: {
        logo: "",
      }
    }
  },
  mounted () {
    var _this = this;
    window.getdata = this.getdata;
    layui.use("upload", function () {
      var upload = layui.upload;
      var uploadInst = upload.render({
        elem: "#test1", //绑定元素
        url: 'https://httpbin.org/post' //改成您自己的上传接口
        , before: function (obj) {
          //预读本地文件示例，不支持ie8
          obj.preview(function (index, file, result) {
            $('#demo1').attr('src', result); //图片链接（base64）
          });
        }
        , done: function (res) {
          //如果上传失败
          if (res.code > 0) {
            return layer.msg('上传失败');
          }
          //上传成功
        }
        , error: function () {
          //演示失败状态，并实现重传
          var demoText = $('#demoText');
          demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
          demoText.find('.demo-reload').on('click', function () {
            uploadInst.upload();
          });
        }
      });
      upload.render({
        elem: "#test2", //绑定元素
        url: 'https://httpbin.org/post' //改成您自己的上传接口
        , before: function (obj) {
          //预读本地文件示例，不支持ie8
          obj.preview(function (index, file, result) {
            $('#demo2').attr('src', result); //图片链接（base64）
          });
        }
        , done: function (res) {
          //如果上传失败
          if (res.code > 0) {
            return layer.msg('上传失败');
          }
          //上传成功
        }
        , error: function () {
          //演示失败状态，并实现重传
          var demoText = $('#demoText');
          demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
          demoText.find('.demo-reload').on('click', function () {
            uploadInst.upload();
          });
        }
      });


    });
  },
  methods: {
  },
  updated: function () {
    var _this = this;
    layui.use('form', function () {
      var form = layui.form;
      form.render();

    });

  },
}
</script>
<style scoped>
</style>